(function () {
    'use strict';

    angular
        .module('logcenterApp')
        .service('platformDashService',platformDashService);

    platformDashService.$inject=['$http','$q'];
    function platformDashService($http,$q) {

        //登录统计
        var queryLoginTotal = function (beginDateTime, endDateTime,active) {
            var deferred=$q.defer();
            $http.get('api/dashboard/loginTotal?startTime=' + beginDateTime
                + '&endTime=' + endDateTime+"&active="+active).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        };
        var queryCallServiceTotal= function (beginDateTime, endDateTime,active) {
            var deferred=$q.defer();
            $http.get('api/dashboard/callServiceTotal?startTime=' + beginDateTime
                + '&endTime=' + endDateTime+"&active="+active).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        };

        var queryFrameTotal= function (beginDateTime, endDateTime,active) {
            var deferred=$q.defer();
            $http.get('api/dashboard/frameTotal?startTime=' + beginDateTime
                + '&endTime=' + endDateTime+"&active="+active).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        };

        var queryAsyncRouteSendTotal= function (beginDateTime, endDateTime,active) {
            var deferred=$q.defer();
            $http.get('api/dashboard/asyncRouteSendTotal?startTime=' + beginDateTime
                + '&endTime=' + endDateTime+"&active="+active).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        };
        var queryAsyncRouteReceiveTotal= function (beginDateTime, endDateTime,active) {
            var deferred=$q.defer();
            $http.get('api/dashboard/asyncRouteReceiveTotal?startTime=' + beginDateTime
                + '&endTime=' + endDateTime+"&active="+active).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        };
        var queryBatchTotal= function (beginDateTime, endDateTime,active) {
            var deferred=$q.defer();
            $http.get('api/dashboard/batchTotal?startTime=' + beginDateTime
                + '&endTime=' + endDateTime+"&active="+active).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        };

        var callServiceLine= function (beginDateTime, endDateTime,interval,active) {
            var deferred=$q.defer();
            $http.get('api/dashboard/callServiceLine?startTime=' + beginDateTime
                + '&endTime=' + endDateTime+"&interval="+interval+"&active="+active).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        };
        var mapService= function (beginDateTime, endDateTime,active) {
            var deferred=$q.defer();
            $http.get('api/dashboard/mapService?startTime=' + beginDateTime
                + '&endTime=' + endDateTime+"&active="+active).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        };
        var asyncRouteLine= function (beginDateTime, endDateTime,interval,active) {
            var deferred=$q.defer();
            $http.get('api/dashboard/asyncRouteLine?startTime=' + beginDateTime
                + '&endTime=' + endDateTime+"&interval="+interval+"&active="+active).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        };
        return {
            queryLoginTotal:queryLoginTotal,
            queryCallServiceTotal:queryCallServiceTotal,
            queryFrameTotal:queryFrameTotal,
            queryAsyncRouteSendTotal:queryAsyncRouteSendTotal,
            queryAsyncRouteReceiveTotal:queryAsyncRouteReceiveTotal,
            queryBatchTotal:queryBatchTotal,
            callServiceLine:callServiceLine,
            mapService:mapService,
            asyncRouteLine:asyncRouteLine

        };
    }
})();
